<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.5.4.1/themes/default/easyui.css">   
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.5.4.1/themes/icon.css">   
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.5.4.1/jquery.min.js"></script>   
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.5.4.1/jquery.easyui.min.js"></script> 

</head>
<body>
<div id="dg"></div>
</body>
<script type="text/javascript">
	$(function(){
		var jsonData=[{"code":"1","name":"李四","price":"23"},{"code":"2","name":"张三","price":"44"}];
		$('#dg').datagrid({    
			data:jsonData,
		    //url:'datagrid_data.json',    
		    columns:[[    
		        {field:'code',title:'代码',width:100},    
		        {field:'name',title:'名称',width:100},    
		        {field:'price',title:'价格',width:100,align:'right'},
		        {field:'Id',title:'爱好', width:80,
				formatter: function(value,row,index){
					if (row.user){
						console.log(row.user.name);
						return row.user.name;
					} else {
						return value;
					}
				}

		    ]]/* ,
		    toolbar: [{
		    	text:'删除用户',
	            iconCls:'icon-remove' ,
	            handler:function(){
	                var arr = $('#dg').datagrid('getSelections');
	                if(arr.length <= 0 ){
	                    $.messager.show({
	                        title:'提示信息',
	                        msg:'请选择进行删除操作!'
	                    });                                            
	                } else {
	                    $.messager.confirm('提示信息' , '确认删除?' , function(r){
	                        if(r){
	                            var ids = '';
	                            for(var i = 0 ; i < arr.length ; i++){
	                                ids += arr[i].id + ',';
	                            }
	                            console.log(ids);
	                            ids = ids.substring(0,ids.length-1);
	                            $.post('UserServlet?method=delete' , {ids:ids},function(result){
	                                    $('#dg').datagrid('reload');
	                                    $.messager.show({
	                                        title:'提示信息',
	                                        msg:'操作成功!'
	                                    });
	                            });
	                            
	                        } else {
	                             return ;
	                        }
	                    });
	                }
	            }
			},'-',{
				iconCls: 'icon-help',
				handler: function(){alert('帮助按钮')}
			}]

		     */
		});  
		
	});

</script>
</html>